package com.wtc.view;

import com.wtc.entity.Student;
import com.wtc.service.StudentService;
import com.wtc.utils.Utility;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Scanner;

public class MybatisDemoTest {
    private boolean loop = true;
    private char key = ' ';
    public void mainMenu() throws IOException{
        StudentService studentService = new StudentService();
        do {
            System.out.println("————————功能列表————————");
            System.out.println("0、退出");
            System.out.println("1、查询");
            System.out.println("2、添加");
            System.out.println("3、修改");
            System.out.println("4、删除");
            System.out.print("输入相应功能序号：");
            key = Utility.readChar();
            switch (key) {
                case '0':
                    loop = false;
                    break;
                case '1':
                    studentService.select();
                    System.out.println("显示完毕！");
                    break;
                case '2':
                    studentService.insert();
                    break;
                case '3':
                    studentService.update();
                    break;
                case '4':
                    studentService.delete();
                    break;
            }
        } while (loop);
    }

}
